package com.example.myapplication.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;

import org.androidannotations.annotations.EService;
import org.androidannotations.annotations.UiThread;

@EService
public class AService extends Service {
    public AService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        showToast();
        return super.onStartCommand(intent, flags, startId);
    }

    /**
     * 方法在主线程调用
     */
    @UiThread
    void showToast() {
        Toast.makeText(getApplicationContext(), "Hello Service", Toast.LENGTH_LONG).show();
    }
}
